const Router = require('koa-router');
const router = new Router();
const tool = require('../../tools/tool')
const {db, QueryTypes} = require("../../models/db");
const {setBillNo, toAccounted} = require("../bill/base");
// 在已派单中增加
router.post('/receipt/addPdList', async ctx => {
    let user = ctx.user
    let tenantId = user.tenantId;
    let body = ctx.request.body;
    let buId = body.buId;
    let list = []
    let sql = `select id billId, buId,buName,billDate,billNo,transType,transTypeName,salesId,salesName,totalAmount,arrearsReal,leftYe leftAmount 
    from v_main_withhx where tenantId=${tenantId} and buId=${buId} and leftYe<>0 
    and id not in (select billId from receipt_pd where receipt_pd.tenantId=${tenantId} and buId=${buId} and state=N'收款中')
    `
    list = await db.query(sql, {type: QueryTypes.SELECT})
    return ctx.suc('', {list})
})


module.exports = router;
